﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Carbon.Web.Forms.Controls;
using Demo.Demos.ComplexDataStructures;
using Person = Demo.Demos.ComplexDataStructures.PersonViewModel;

namespace Demo.Demos
{
    public class ComplexDataStructuresDataContext : DataContextControl<ComplexDataStructuresViewModel>
    {
        protected override ComplexDataStructuresViewModel CreateViewModel()
        {
            ComplexDataStructuresViewModel vm = new ComplexDataStructuresViewModel();

            // initialize it with dummy data
            PersonViewModel person = new Person(vm);
            person.Name = "Siemowit Aodh";
            person.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar1.jpg";

            {
                PersonViewModel person1 = new Person(vm);
                person1.Name = "Fortunato Matthei";
                person1.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar2.jpg";

                PersonViewModel person2 = new Person(vm);
                person2.Name = "Bai Andreas";
                person2.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar3.jpg";
                

                PersonViewModel person3 = new Person(vm);
                person3.Name = "Haider Gilbert";
                person3.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar1.jpg";
                person3.IsNodeExpanded = false;

                PersonViewModel person4 = new Person(vm);
                person4.Name = "Pratap Archie";
                person4.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar2.jpg";
                person4.IsNodeExpanded = false;

                PersonViewModel person5 = new Person(vm);
                person5.Name = "Gennadios Achaikos";
                person5.IsNodeExpanded = false;
                person5.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar5.jpg";

                person.AddNewSubordinate(person1, person2, person3, person4, person5);
                
                {
                    PersonViewModel person21 = new Person(vm);
                    person21.Name = "Alphaeus Vulferam";
                    person21.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar4.jpg";

                    PersonViewModel person22 = new Person(vm);
                    person22.Name = "Rodrigo Dagan";
                    person22.AvatarPicture = "/Demos/ComplexDataStructures/img/avatar5.jpg";

                    person2.AddNewSubordinate(person21, person22);

                    // Simulate networking effect
                    person1.AddNewFriends(person22);
                    person2.AddNewFriends(person22);
                    person3.AddNewFriends(person22);
                    person4.AddNewFriends(person22);
                    person5.AddNewFriends(person22);
                }
                
                // add conspiracy against Boss
                person.AddNewFriends(person1, person2);
                
                person1.AddNewFriends(person3);
                person2.AddNewFriends(person1, person3);
                person3.AddNewFriends(person1, person2);
            }

            vm.ShowTop = 3;
            vm.LevelFactor = 1.5f;
            vm.OneSideFriendFactor = 0.3f;
            vm.FriendFactor = 1;

            vm.RootPerson = person;
            vm.RootPerson.SelectCurrent();

            return vm;
        }
    }
}